﻿Class MainWindow
    Private Const VK_MENU As Integer = &H12
    Dim WithEvents KbdHook As KeyboardHook

    ''' <summary>
    ''' 圆角矩形的鼠标事件
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    Private Sub Path_MouseDown(sender As Object, e As MouseButtonEventArgs)
        If e.LeftButton = MouseButtonState.Pressed Then
            ' /* 双击圆角矩形退出. */
            If e.ClickCount = 2 Then
                Close()
            End If

            ' 单击圆环移动.
            DragMove()
        End If
    End Sub

    Private Sub MainWindow_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
        Try
            KbdHook = New KeyboardHook()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    ''' <summary>
    ''' 游戏中使用 Alt + 方向键进行微调.
    ''' </summary>
    ''' <param name="WPFKey"></param>
    Private Sub KbdHook_KeyDown(WPFKey As Key) Handles KbdHook.KeyDown
        ' /* 按下 Alt 键. */
        If KbdHook.GetKS(VK_MENU) Then
            Select Case WPFKey
                Case Key.Left
                    Left = Left - 1
                Case Key.Right
                    Left = Left + 1
                Case Key.Up
                    Top = Top - 1
                Case Key.Down
                    Top = Top + 1
            End Select
        End If
    End Sub
End Class